package com.kunbo.service;

import com.kunbo.entity.Bearing;
import com.kunbo.mathutil.FFT;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
@Service
public class FFTServer {

    @Autowired
    private BearingService bearingService;
    @Autowired
    private FFT fft;
    //输出x的fft结果
    public List<Double> runFFTForX(){
        List<Bearing> x = bearingService.getX();
        List<Double> inputData = new ArrayList<>();
        for(Bearing bearing : x){
            inputData.add(bearing.getX());
        }
        List<Double> dataFFT = fft.start(inputData);
        return dataFFT;
    }

    //输出对应的频率点
    public List<Double> frequency(){
        return fft.getFrequency();
    }

}
